$(document).ready(function(){
	jumpPage_maintain_history_list(1);
	
	addFadeEffect();
});

function jumpPage_maintain_history_list(targetPage) {
	var requestUrl = "get_maintain_history";
	var carLicense;
	
	if (customers == null) {
		carLicense = selectedMaintainOrderLicense;
	} else {
		carLicense = customers[selectedCusutomerIndex].carLicense;
	}
	
	var params = {
		car_license:carLicense,
		page:targetPage,
		pageSize:5
	};
	
	$.post(requestUrl, params, function(ret){
		$("#div_maintain_history_list").html("");
		var newHtml = "";
		var item;
		var pages = 1;
		var status = "";
		
		histories = ret.resultData.items;
		
		//显示结果列表
		for (var i = 0; ret.resultData.items && i < ret.resultData.items.length; i++) {
			item = ret.resultData.items[i];
			
			switch (item.status) {
			case "0":
				status = "等待养护";
				break;
			case "1":
				status = "等待用户确认";
				break;
			case "2":
				status = "等待评价";
				break;
			case "3":
				status = "已完成";
				break;
			default:
				break;
			}
			
			newHtml += '<div class="order_item" style="padding-top: 2px" onmouseover="selectMaintainItem(this);" onclick="showMaintainOrderDetail(\'' + item.id + '\');">';
			newHtml += '	<div class="col_maintain_date">' + item.maintainDate + '</div>';
			newHtml += '	<div class="col_mileage">' + item.mileage + '</div>';
			newHtml += '	<div class="col_license">' + item.licenseNumber + '</div>';
			newHtml += '	<div class="col_status">' + status + '</div>';
			newHtml += '	<div style="clear: both;"></div>';
			newHtml += '</div>';
		}
		
		//显示分页信息
		if (ret.resultData.total_num && ret.resultData.total_num > 5) {
			pages = Math.ceil(ret.resultData.total_num/5);
			var page = new Page(pages);
			page.currentPage = targetPage;
			newHtml += page.genPageHtml("jumpPage_maintain_history_list");
		}
		
		$("#div_maintain_history_list").html(newHtml);
	}, dataType="json");
}